package com.homework.T2;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * @author xiyu
 * @version 1.0
 * @date 2025/4/2 17:48
 * @description
 */
public class Test {
    public static void main(String[] args) {
        HashMap<Student,String> stumap = new HashMap<>();
        stumap.put(new Student("张三",18),"张三路xx号");
        stumap.put(new Student("李四",19),"李四路xx号");
        stumap.put(new Student("王五",20),"王五路xx号");

        Set<Map.Entry<Student, String>> entries = stumap.entrySet();
        for (Map.Entry<Student, String> entry : entries) {
            System.out.println(entry.getKey()+":"+entry.getValue());
        }
        System.out.println("----------------------------");
        Set<Student> students = stumap.keySet();
        for (Student student : students) {
            System.out.println(student+":"+stumap.get(student));
        }
        System.out.println("----------------------------");
        Iterator<Student> iterator = stumap.keySet().iterator();
        while (iterator.hasNext()){
            Student key = iterator.next();
            System.out.println(key+":"+stumap.get(key));
        }
        System.out.println("----------------------------");
        Iterator<Map.Entry<Student, String>> iterator1 = stumap.entrySet().iterator();
        while (iterator1.hasNext()) {
            Map.Entry<Student, String> v = iterator1.next();
            System.out.println(v.getKey()+":"+v.getValue());
        }
    }
}
